package com.nai365.nart.order.api.feign;

import com.nai365.nart.common.core.constant.SecurityConstants;
import com.nai365.nart.common.core.constant.ServiceNameConstants;
import com.nai365.nart.common.core.util.R;
import com.nai365.nart.common.security.annotation.Inner;
import com.nai365.nart.order.entity.Order;
import com.nai365.nart.order.entity.OrderItem;
import com.nai365.nart.order.to.DrawOrderTo;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
 * 库存系统
 */
@FeignClient(ServiceNameConstants.ORDER_SERVICE)
public interface OrderFeignService {

	/**
	 * 抽签创建订单
	 */
	//TODO
	@PostMapping(value = "/order/draw_create_order")
	R<List<DrawOrderTo>> drawCreateOrder(@RequestBody Map<Long, Long> ids, @RequestHeader(SecurityConstants.FROM) String from);


	/**
	 * 支付回调
	 */
	@PostMapping(value = "/callback/pay_callback")
	R payCallback(@RequestBody String data, @RequestHeader(SecurityConstants.FROM) String from);

	/**
	 * 提现回调
	 */
	@PostMapping(value = "/callback/draw_callback")
	R drawCallback(@RequestBody String data, @RequestHeader(SecurityConstants.FROM) String from);


	@GetMapping("/order/findOrderByOrderId/{orderSn}")
	public R<Order> findOrderByOrderId(@PathVariable("orderSn") String orderSn, @RequestHeader(SecurityConstants.FROM) String from);

	@GetMapping("/orderitem/findOrderItemByOrderId/{orderId}")
	public OrderItem findOrderItemByOrderId(@PathVariable("orderId") Long orderId, @RequestHeader(SecurityConstants.FROM) String from);

	@GetMapping("/order/check_no_pay")
	public R checkNoPay(@RequestParam("userId") Long userId, @RequestHeader(SecurityConstants.FROM) String from);


	@GetMapping("/order/modifyOrderStatus/{orderId}/{status}")
	public void modifyOrderStatus(@PathVariable("orderId") String orderId, @PathVariable("status") Integer status, @RequestHeader(SecurityConstants.FROM) String from);


	/**
	 * 根据 sku id列表查询已支付的订单项
	 *
	 * @param skuIdList idList
	 * @return R<List < OrderItem>>
	 */
	@GetMapping("/orderitem/payed/ids")
	R<List<OrderItem>> findPayedBySkuIdList(@RequestParam(value = "skuIdList") Collection<Long> skuIdList, @RequestHeader(SecurityConstants.FROM) String from);
}
